package com.spring.data.jdbc.entity;

import lombok.*;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.PersistenceConstructor;
import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.Table;

import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import java.io.Serializable;
import java.util.Date;

/**
 * UserInfo
 *
 * @author: chenfenghai
 * @version: 1.0
 * @date: 2020-06-10 14:29
 * @blame Team
 */
@Data
@Table("U_USER_INFO")
public class UserInfo implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    private String name;

    @Enumerated(EnumType.ORDINAL)
    private GenderEnum gender;

    @Column("CREATE_TIME")
    private Date createTime;

    @Column("UPDATE_TIME")
    private Date updateTime;

    @PersistenceConstructor
    public UserInfo(){}

    public enum GenderEnum {
        /**
         * 男
         */
        MALE(0,"男"),

        /**
         * 女
         */
        FEMALE(1, "女");

        /**
         * 编码
         */
        private int code;

        /**
         * 文字
         */
        private String text;

        GenderEnum(int code, String text){
            this.code = code;
            this.text = text;
        }
    }
}
